/*
               File: GXLRI51
        Description: Load referential integrity
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 27 de Setiembre de 2010 11:53:24.42
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class gxlri51 extends GXProcedure
{
   public gxlri51( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( gxlri51.class ), "" );
   }

   public gxlri51( int remoteHandle ,
                   ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor GXLRI512 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A539CmbCod = GXLRI512_A539CmbCod[0] ;
         A519MVehCo = GXLRI512_A519MVehCo[0] ;
         /*
            INSERT RECORD ON TABLE MMCMB10

         */
         W523CmbCod = A523CmbCod ;
         W523CmbCod = A523CmbCod ;
         W578CmbNom = A578CmbNom ;
         W578CmbNom = A578CmbNom ;
         W579CmbEst = A579CmbEst ;
         W579CmbEst = A579CmbEst ;
         W580CmbFCR = A580CmbFCR ;
         W580CmbFCR = A580CmbFCR ;
         W581CmbHCR = A581CmbHCR ;
         W581CmbHCR = A581CmbHCR ;
         W582CmbUCR = A582CmbUCR ;
         W582CmbUCR = A582CmbUCR ;
         W583CmbFUM = A583CmbFUM ;
         W583CmbFUM = A583CmbFUM ;
         W584CmbHUM = A584CmbHUM ;
         W584CmbHUM = A584CmbHUM ;
         W585CmbUUM = A585CmbUUM ;
         W585CmbUUM = A585CmbUUM ;
         if ( ((0==A523CmbCod)) )
         {
            A523CmbCod = 0 ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A578CmbNom))==0)) )
         {
            A578CmbNom = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A579CmbEst))==0)) )
         {
            A579CmbEst = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A580CmbFCR)) )
         {
            A580CmbFCR = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A581CmbHCR))==0)) )
         {
            A581CmbHCR = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A582CmbUCR))==0)) )
         {
            A582CmbUCR = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A583CmbFUM)) )
         {
            A583CmbFUM = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A584CmbHUM))==0)) )
         {
            A584CmbHUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A585CmbUUM))==0)) )
         {
            A585CmbUUM = "" ;
         }
         else
         {
         }
         /* Using cursor GXLRI513 */
         pr_default.execute(1, new Object[] {new Integer(A523CmbCod), A578CmbNom, A579CmbEst, A580CmbFCR, A581CmbHCR, A582CmbUCR, A583CmbFUM, A584CmbHUM, A585CmbUUM});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         A523CmbCod = W523CmbCod ;
         A523CmbCod = W523CmbCod ;
         A578CmbNom = W578CmbNom ;
         A578CmbNom = W578CmbNom ;
         A579CmbEst = W579CmbEst ;
         A579CmbEst = W579CmbEst ;
         A580CmbFCR = W580CmbFCR ;
         A580CmbFCR = W580CmbFCR ;
         A581CmbHCR = W581CmbHCR ;
         A581CmbHCR = W581CmbHCR ;
         A582CmbUCR = W582CmbUCR ;
         A582CmbUCR = W582CmbUCR ;
         A583CmbFUM = W583CmbFUM ;
         A583CmbFUM = W583CmbFUM ;
         A584CmbHUM = W584CmbHUM ;
         A584CmbHUM = W584CmbHUM ;
         A585CmbUUM = W585CmbUUM ;
         A585CmbUUM = W585CmbUUM ;
         /* End Insert */
         /* Check if program is canceled. */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      GXLRI512_A539CmbCod = new int[1] ;
      GXLRI512_A519MVehCo = new short[1] ;
      A539CmbCod = 0 ;
      A519MVehCo = 0 ;
      GX_INS51 = 0 ;
      W523CmbCod = 0 ;
      A523CmbCod = 0 ;
      W578CmbNom = "" ;
      A578CmbNom = "" ;
      W579CmbEst = "" ;
      A579CmbEst = "" ;
      W580CmbFCR = GXutil.nullDate() ;
      A580CmbFCR = GXutil.nullDate() ;
      W581CmbHCR = "" ;
      A581CmbHCR = "" ;
      W582CmbUCR = "" ;
      A582CmbUCR = "" ;
      W583CmbFUM = GXutil.nullDate() ;
      A583CmbFUM = GXutil.nullDate() ;
      W584CmbHUM = "" ;
      A584CmbHUM = "" ;
      W585CmbUUM = "" ;
      A585CmbUUM = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new gxlri51__default(),
         new Object[] {
             new Object[] {
            GXLRI512_A539CmbCod, GXLRI512_A519MVehCo
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A519MVehCo ;
   private short Gx_err ;
   private int A539CmbCod ;
   private int GX_INS51 ;
   private int W523CmbCod ;
   private int A523CmbCod ;
   private String W578CmbNom ;
   private String A578CmbNom ;
   private String W579CmbEst ;
   private String A579CmbEst ;
   private String W581CmbHCR ;
   private String A581CmbHCR ;
   private String W582CmbUCR ;
   private String A582CmbUCR ;
   private String W584CmbHUM ;
   private String A584CmbHUM ;
   private String W585CmbUUM ;
   private String A585CmbUUM ;
   private String Gx_emsg ;
   private java.util.Date W580CmbFCR ;
   private java.util.Date A580CmbFCR ;
   private java.util.Date W583CmbFUM ;
   private java.util.Date A583CmbFUM ;
   private IDataStoreProvider pr_default ;
   private int[] GXLRI512_A539CmbCod ;
   private short[] GXLRI512_A519MVehCo ;
}

final class gxlri51__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("GXLRI512", "SELECT [CmbCodCnv], [MVehCod] FROM [MMVEH10] WITH (NOLOCK) ORDER BY [MVehCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("GXLRI513", "INSERT INTO [MMCMB10] ([CmbCod], [CmbNom], [CmbEst], [CmbFCR], [CmbHCR], [CmbUCR], [CmbFUM], [CmbHUM], [CmbUUM]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((int[]) buf[0])[0] = rslt.getInt(1) ;
               ((short[]) buf[1])[0] = rslt.getShort(2) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setInt(1, ((Integer) parms[0]).intValue());
               stmt.setString(2, (String)parms[1], 50);
               stmt.setString(3, (String)parms[2], 1);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setString(6, (String)parms[5], 10);
               stmt.setDate(7, (java.util.Date)parms[6]);
               stmt.setString(8, (String)parms[7], 8);
               stmt.setString(9, (String)parms[8], 10);
               break;
      }
   }

}

